package com.qezhhnjy.cloud.rabbitmq.demo;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author zhaoyangfu - 2020/7/31 15:16
 */
@Component
public class Producer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void produce() {
        String msg = new Date().toString();
        System.out.println("msg = " + msg);
        rabbitTemplate.convertAndSend("rabbitmq_queue", msg);
    }
}
